import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error)
}

const routes = [
  {
    path: "/",
    name: "Home",
    component: resolve => require(['@/views/homePage/home'], resolve)
  },
  {
    path: "/readMore",
    name: "readMore",
    component: resolve => require(['@/views/goodsPage/goods'], resolve)
  },
  {
    path: "/goodsCart",
    name: "goodsCart",
    component: resolve => require(['@/views/goodsPage/goodsCart'], resolve)
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
});

export default router;
